package com.ssfGame.puremvc.controller.load
{
	
	
	import com.adobe.serialization.json.JSON;
	import com.game.alert.AlertCtrl;
	import com.game.utils.GlobalFun;
	import com.ssfGame.puremvc.StaticConst;
	import com.ssfGame.puremvc.model.vo.ConfigVO;
	import com.ssfGame.puremvc.model.vo.LoadVO;
	import com.ssfGame.puremvc.view.module.queueload.QueueLoadPanelMediator;
	import com.ssfGame.puremvc.view.module.queueload.vo.QueueLoadVO;
	
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.command.SimpleCommand;
	
	/**
	 * 加载游戏初始化数据()
	 * @author chery
	 */
	public class LoadInitLoadCommand extends SimpleCommand
	{
		private var _configVO:ConfigVO ;
		public function LoadInitLoadCommand()
		{
			super();
		}
		override public function execute(notification:INotification):void{
			_configVO=StaticConst.configVO
			var tempLoadVO:LoadVO;
			var tempQueueLoadVO:QueueLoadVO=new QueueLoadVO();
			tempQueueLoadVO.callBakcFun=onComplete;
			for(var n:int=0;n<_configVO.INITLOADER.length;n++){
				tempLoadVO=new LoadVO();
				tempLoadVO.domain = 2;
				tempLoadVO.url=StaticConst.RESOURCE_URL+_configVO.INITLOADER[n].URL;
				tempLoadVO.type=_configVO.INITLOADER[n].TYPE;
				tempQueueLoadVO.loadVec.push(tempLoadVO);
			}
			if(tempQueueLoadVO.loadVec.length>0){
			sendNotification(StaticConst.N_C_LOAD,tempQueueLoadVO);
			}else{
				sendNotification(StaticConst.N_C_LOAD_COMMON);
			}
		}
		private function onComplete(qVO:QueueLoadVO=null):void{
			
			for(var n:int=0;n<qVO.loadVec.length;n++){
				if(qVO.loadVec[n].type==StaticConst.V_JSON){
					initLoadVO(qVO.loadVec[n]);
				}
			}
			facade.registerMediator(new QueueLoadPanelMediator(QueueLoadPanelMediator.NAME));
			sendNotification(StaticConst.N_C_LOAD_COMMON);
		}

		private function initLoadVO(lVO:LoadVO):void{
			switch(lVO.url){
				/*
				case StaticConst.RESOURCE_URL+_configVO.INITLOADER[0].URL:
					break;
				case StaticConst.RESOURCE_URL+_configVO.INITLOADER[1].URL:
					break;
				*/
			}
			
		}
	}
}